<?php

class Default_Model_Faq extends Zend_Db_Table {

    protected $_name = 'faq';
    protected $_primary = 'faqid';

    public function faqItem($arrParam = null, $option = null) {
        $db = Zend_Registry::get('connectDb');
        //$db = Zend_Db::factory($adapter, $config);
        $lang = (isset($arrParam['lang'])) ? $arrParam['lang'] : 'en';
        $sql = "";
        if ($lang == 'vi') {
            $sql = $db->query("SELECT faqid, title_vi AS title FROM faq AS f WHERE status = 1 ");
        } else {
            $sql = $db->query("SELECT faqid, title AS title FROM faq AS f WHERE status = 1 ");
        }

        if ($option['task'] == 'faq') {
            $result = $sql->fetchAll();
        }

        return $result;
    }

    public function contentFaq($arrParam = null, $option = null) {
        $db = Zend_Registry::get('connectDb');        
        if ($option['task'] == 'answer') {
            $lang = (isset($arrParam['lang'])) ? $arrParam['lang'] : 'en';
            $sql = "";
            $id = $arrParam['id'];
            if ($lang == 'vi') {
                $sql = $db->query("SELECT faqid, title_vi AS title, content_vi AS content, status FROM faq AS f WHERE faqid = '$id' ");
            } else {
                $sql = $db->query("SELECT faqid, title AS title, content AS content, status FROM faq AS f WHERE faqid = '$id' ");
            }
            $result = $sql->fetchAll();
        }
        return $result;
    }

}